<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="utf-8">
    <title>JSDoc: Class: Resultset</title>

    <script src="scripts/prettify/prettify.js"> </script>
    <script src="scripts/prettify/lang-css.js"> </script>
    <!--[if lt IE 9]>
      <script src="//html5shiv.googlecode.com/svn/trunk/html5.js"></script>
    <![endif]-->
    <link type="text/css" rel="stylesheet" href="styles/prettify-tomorrow.css">
    <link type="text/css" rel="stylesheet" href="styles/jsdoc-default.css">
</head>

<body>

<div id="main">

    <h1 class="page-title">Class: Resultset</h1>

    




<section>

<header>
    
        <h2><span class="attribs"><span class="type-signature"></span></span>Resultset<span class="signature">(collection)</span><span class="type-signature"></span></h2>
        
    
</header>

<article>
    <div class="container-overview">
    
        

    

    
    <h4 class="name" id="Resultset"><span class="type-signature"></span>new Resultset<span class="signature">(collection)</span><span class="type-signature"></span></h4>
    

    



<div class="description">
    <p>Resultset class allowing chainable queries.  Intended to be instanced internally.
   Collection.find(), Collection.where(), and Collection.chain() instantiate this.</p>
</div>









    <h5>Parameters:</h5>
    

<table class="params">
    <thead>
    <tr>
        
        <th>Name</th>
        

        <th>Type</th>

        

        

        <th class="last">Description</th>
    </tr>
    </thead>

    <tbody>
    

        <tr>
            
                <td class="name"><code>collection</code></td>
            

            <td class="type">
            
                
<span class="param-type"><a href="Collection.html">Collection</a></span>


            
            </td>

            

            

            <td class="description last"><p>The collection which this Resultset will query against.</p></td>
        </tr>

    
    </tbody>
</table>






<dl class="details">

    

    

    

    

    

    

    

    

    

    

    

    

    
    <dt class="tag-source">Source:</dt>
    <dd class="tag-source"><ul class="dummy"><li>
        <a href="lokijs.js.html">lokijs.js</a>, <a href="lokijs.js.html#line2758">line 2758</a>
    </li></ul></dd>
    

    

    

    
</dl>

















    <h5>Example</h5>
    
    <pre class="prettyprint"><code>mycollection.chain()     .find({ 'doors' : 4 })     .where(function(obj) { return obj.name === 'Toyota' })     .data();</code></pre>



    
    </div>

    

    

    

    

    

    

    
        <h3 class="subsection-title">Members</h3>

        
            
<h4 class="name" id="branch"><span class="type-signature"></span>branch<span class="type-signature"></span></h4>




<div class="description">
    <p>Alias of copy()</p>
</div>







<dl class="details">

    

    

    

    

    

    

    

    

    

    

    

    

    
    <dt class="tag-source">Source:</dt>
    <dd class="tag-source"><ul class="dummy"><li>
        <a href="lokijs.js.html">lokijs.js</a>, <a href="lokijs.js.html#line2869">line 2869</a>
    </li></ul></dd>
    

    

    

    
</dl>






        
    

    
        <h3 class="subsection-title">Methods</h3>

        
            

    

    
    <h4 class="name" id="compoundsort"><span class="type-signature"></span>compoundsort<span class="signature">(properties)</span><span class="type-signature"> &rarr; {<a href="Resultset.html">Resultset</a>}</span></h4>
    

    



<div class="description">
    <p>Allows sorting a resultset based on multiple columns.</p>
</div>









    <h5>Parameters:</h5>
    

<table class="params">
    <thead>
    <tr>
        
        <th>Name</th>
        

        <th>Type</th>

        

        

        <th class="last">Description</th>
    </tr>
    </thead>

    <tbody>
    

        <tr>
            
                <td class="name"><code>properties</code></td>
            

            <td class="type">
            
                
<span class="param-type">array</span>


            
            </td>

            

            

            <td class="description last"><p>array of property names or subarray of [propertyname, isdesc] used evaluate sort order</p></td>
        </tr>

    
    </tbody>
</table>






<dl class="details">

    

    

    

    

    

    

    

    

    

    

    

    

    
    <dt class="tag-source">Source:</dt>
    <dd class="tag-source"><ul class="dummy"><li>
        <a href="lokijs.js.html">lokijs.js</a>, <a href="lokijs.js.html#line3139">line 3139</a>
    </li></ul></dd>
    

    

    

    
</dl>













<h5>Returns:</h5>

        
<div class="param-desc">
    <p>Reference to this resultset, sorted, for future chain operations.</p>
</div>



<dl>
    <dt>
        Type
    </dt>
    <dd>
        
<span class="param-type"><a href="Resultset.html">Resultset</a></span>


    </dd>
</dl>

    




    <h5>Example</h5>
    
    <pre class="prettyprint"><code>// to sort by age and then name (both ascending)rs.compoundsort(['age', 'name']);// to sort by age (ascending) and then by name (descending)rs.compoundsort(['age', ['name', true]);</code></pre>



        
            

    

    
    <h4 class="name" id="copy"><span class="type-signature"></span>copy<span class="signature">()</span><span class="type-signature"> &rarr; {<a href="Resultset.html">Resultset</a>}</span></h4>
    

    



<div class="description">
    <p>copy() - To support reuse of resultset in branched query situations.</p>
</div>













<dl class="details">

    

    

    

    

    

    

    

    

    

    

    

    

    
    <dt class="tag-source">Source:</dt>
    <dd class="tag-source"><ul class="dummy"><li>
        <a href="lokijs.js.html">lokijs.js</a>, <a href="lokijs.js.html#line2854">line 2854</a>
    </li></ul></dd>
    

    

    

    
</dl>













<h5>Returns:</h5>

        
<div class="param-desc">
    <p>Returns a copy of the resultset (set) but the underlying document references will be the same.</p>
</div>



<dl>
    <dt>
        Type
    </dt>
    <dd>
        
<span class="param-type"><a href="Resultset.html">Resultset</a></span>


    </dd>
</dl>

    





        
            

    

    
    <h4 class="name" id="count"><span class="type-signature"></span>count<span class="signature">()</span><span class="type-signature"> &rarr; {number}</span></h4>
    

    



<div class="description">
    <p>count() - returns the number of documents in the resultset.</p>
</div>













<dl class="details">

    

    

    

    

    

    

    

    

    

    

    

    

    
    <dt class="tag-source">Source:</dt>
    <dd class="tag-source"><ul class="dummy"><li>
        <a href="lokijs.js.html">lokijs.js</a>, <a href="lokijs.js.html#line3541">line 3541</a>
    </li></ul></dd>
    

    

    

    
</dl>













<h5>Returns:</h5>

        
<div class="param-desc">
    <p>The number of documents in the resultset.</p>
</div>



<dl>
    <dt>
        Type
    </dt>
    <dd>
        
<span class="param-type">number</span>


    </dd>
</dl>

    




    <h5>Example</h5>
    
    <pre class="prettyprint"><code>var over30Count = users.chain().find({ age: { $gte: 30 } }).count();</code></pre>



        
            

    

    
    <h4 class="name" id="data"><span class="type-signature"></span>data<span class="signature">(options<span class="signature-attributes">opt</span>)</span><span class="type-signature"> &rarr; {array}</span></h4>
    

    



<div class="description">
    <p>Terminates the chain and returns array of filtered documents</p>
</div>









    <h5>Parameters:</h5>
    

<table class="params">
    <thead>
    <tr>
        
        <th>Name</th>
        

        <th>Type</th>

        
        <th>Attributes</th>
        

        

        <th class="last">Description</th>
    </tr>
    </thead>

    <tbody>
    

        <tr>
            
                <td class="name"><code>options</code></td>
            

            <td class="type">
            
                
<span class="param-type">object</span>


            
            </td>

            
                <td class="attributes">
                
                    &lt;optional><br>
                

                

                
                </td>
            

            

            <td class="description last"><p>allows specifying 'forceClones' and 'forceCloneMethod' options.</p>
                <h6>Properties</h6>
                

<table class="params">
    <thead>
    <tr>
        
        <th>Name</th>
        

        <th>Type</th>

        

        

        <th class="last">Description</th>
    </tr>
    </thead>

    <tbody>
    

        <tr>
            
                <td class="name"><code>forceClones</code></td>
            

            <td class="type">
            
                
<span class="param-type">boolean</span>


            
            </td>

            

            

            <td class="description last"><p>Allows forcing the return of cloned objects even when
       the collection is not configured for clone object.</p></td>
        </tr>

    

        <tr>
            
                <td class="name"><code>forceCloneMethod</code></td>
            

            <td class="type">
            
                
<span class="param-type">string</span>


            
            </td>

            

            

            <td class="description last"><p>Allows overriding the default or collection specified cloning method.
       Possible values include 'parse-stringify', 'jquery-extend-deep', 'shallow', 'shallow-assign'</p></td>
        </tr>

    

        <tr>
            
                <td class="name"><code>removeMeta</code></td>
            

            <td class="type">
            
                
<span class="param-type">bool</span>


            
            </td>

            

            

            <td class="description last"><p>Will force clones and strip $loki and meta properties from documents</p></td>
        </tr>

    
    </tbody>
</table>

            </td>
        </tr>

    
    </tbody>
</table>






<dl class="details">

    

    

    

    

    

    

    

    

    

    

    

    

    
    <dt class="tag-source">Source:</dt>
    <dd class="tag-source"><ul class="dummy"><li>
        <a href="lokijs.js.html">lokijs.js</a>, <a href="lokijs.js.html#line3563">line 3563</a>
    </li></ul></dd>
    

    

    

    
</dl>













<h5>Returns:</h5>

        
<div class="param-desc">
    <p>Array of documents in the resultset</p>
</div>



<dl>
    <dt>
        Type
    </dt>
    <dd>
        
<span class="param-type">array</span>


    </dd>
</dl>

    




    <h5>Example</h5>
    
    <pre class="prettyprint"><code>var resutls = users.chain().find({ age: 34 }).data();</code></pre>



        
            

    

    
    <h4 class="name" id="eqJoin"><span class="type-signature"></span>eqJoin<span class="signature">(joinData, leftJoinKey, rightJoinKey, mapFun<span class="signature-attributes">opt</span>, dataOptions<span class="signature-attributes">opt</span>)</span><span class="type-signature"> &rarr; {<a href="Resultset.html">Resultset</a>}</span></h4>
    

    



<div class="description">
    <p>eqJoin() - Left joining two sets of data. Join keys can be defined or calculated properties
eqJoin expects the right join key values to be unique.  Otherwise left data will be joined on the last joinData object with that key</p>
</div>









    <h5>Parameters:</h5>
    

<table class="params">
    <thead>
    <tr>
        
        <th>Name</th>
        

        <th>Type</th>

        
        <th>Attributes</th>
        

        

        <th class="last">Description</th>
    </tr>
    </thead>

    <tbody>
    

        <tr>
            
                <td class="name"><code>joinData</code></td>
            

            <td class="type">
            
                
<span class="param-type">Array</span>
|

<span class="param-type"><a href="Resultset.html">Resultset</a></span>
|

<span class="param-type"><a href="Collection.html">Collection</a></span>


            
            </td>

            
                <td class="attributes">
                

                

                
                </td>
            

            

            <td class="description last"><p>Data array to join to.</p></td>
        </tr>

    

        <tr>
            
                <td class="name"><code>leftJoinKey</code></td>
            

            <td class="type">
            
                
<span class="param-type">string</span>
|

<span class="param-type">function</span>


            
            </td>

            
                <td class="attributes">
                

                

                
                </td>
            

            

            <td class="description last"><p>Property name in this result set to join on or a function to produce a value to join on</p></td>
        </tr>

    

        <tr>
            
                <td class="name"><code>rightJoinKey</code></td>
            

            <td class="type">
            
                
<span class="param-type">string</span>
|

<span class="param-type">function</span>


            
            </td>

            
                <td class="attributes">
                

                

                
                </td>
            

            

            <td class="description last"><p>Property name in the joinData to join on or a function to produce a value to join on</p></td>
        </tr>

    

        <tr>
            
                <td class="name"><code>mapFun</code></td>
            

            <td class="type">
            
                
<span class="param-type">function</span>


            
            </td>

            
                <td class="attributes">
                
                    &lt;optional><br>
                

                

                
                </td>
            

            

            <td class="description last"><p>(Optional) A function that receives each matching pair and maps them into output objects - function(left,right){return joinedObject}</p></td>
        </tr>

    

        <tr>
            
                <td class="name"><code>dataOptions</code></td>
            

            <td class="type">
            
                
<span class="param-type">object</span>


            
            </td>

            
                <td class="attributes">
                
                    &lt;optional><br>
                

                

                
                </td>
            

            

            <td class="description last"><p>options to data() before input to your map function</p>
                <h6>Properties</h6>
                

<table class="params">
    <thead>
    <tr>
        
        <th>Name</th>
        

        <th>Type</th>

        

        

        <th class="last">Description</th>
    </tr>
    </thead>

    <tbody>
    

        <tr>
            
                <td class="name"><code>removeMeta</code></td>
            

            <td class="type">
            
                
<span class="param-type">bool</span>


            
            </td>

            

            

            <td class="description last"><p>allows removing meta before calling mapFun</p></td>
        </tr>

    

        <tr>
            
                <td class="name"><code>forceClones</code></td>
            

            <td class="type">
            
                
<span class="param-type">boolean</span>


            
            </td>

            

            

            <td class="description last"><p>forcing the return of cloned objects to your map object</p></td>
        </tr>

    

        <tr>
            
                <td class="name"><code>forceCloneMethod</code></td>
            

            <td class="type">
            
                
<span class="param-type">string</span>


            
            </td>

            

            

            <td class="description last"><p>Allows overriding the default or collection specified cloning method.</p></td>
        </tr>

    
    </tbody>
</table>

            </td>
        </tr>

    
    </tbody>
</table>






<dl class="details">

    

    

    

    

    

    

    

    

    

    

    

    

    
    <dt class="tag-source">Source:</dt>
    <dd class="tag-source"><ul class="dummy"><li>
        <a href="lokijs.js.html">lokijs.js</a>, <a href="lokijs.js.html#line3777">line 3777</a>
    </li></ul></dd>
    

    

    

    
</dl>













<h5>Returns:</h5>

        
<div class="param-desc">
    <p>A resultset with data in the format [{left: leftObj, right: rightObj}]</p>
</div>



<dl>
    <dt>
        Type
    </dt>
    <dd>
        
<span class="param-type"><a href="Resultset.html">Resultset</a></span>


    </dd>
</dl>

    




    <h5>Example</h5>
    
    <pre class="prettyprint"><code>var db = new loki('sandbox.db');var products = db.addCollection('products');var orders = db.addCollection('orders');products.insert({ productId: "100234", name: "flywheel energy storage", unitCost: 19999.99 });products.insert({ productId: "140491", name: "300F super capacitor", unitCost: 129.99 });products.insert({ productId: "271941", name: "fuel cell", unitCost: 3999.99 });products.insert({ productId: "174592", name: "390V 3AH lithium bank", unitCost: 4999.99 });orders.insert({ orderDate : new Date("12/1/2017").getTime(), prodId: "174592", qty: 2, customerId: 2 });orders.insert({ orderDate : new Date("4/15/2016").getTime(), prodId: "271941", qty: 1, customerId: 1 });orders.insert({ orderDate : new Date("3/12/2017").getTime(), prodId: "140491", qty: 4, customerId: 4 });orders.insert({ orderDate : new Date("7/31/2017").getTime(), prodId: "100234", qty: 7, customerId: 3 });orders.insert({ orderDate : new Date("8/3/2016").getTime(), prodId: "174592", qty: 3, customerId: 5 });var mapfun = function(left, right) {  return {    orderId: left.$loki,    orderDate: new Date(left.orderDate) + '',    customerId: left.customerId,    qty: left.qty,    productId: left.prodId,    prodName: right.name,    prodCost: right.unitCost,    orderTotal: +((right.unitCost * left.qty).toFixed(2))  };};// join orders with relevant product info via eqJoinvar orderSummary = orders.chain().eqJoin(products, "prodId", "productId", mapfun).data();console.log(orderSummary);     </code></pre>



        
            

    

    
    <h4 class="name" id="find"><span class="type-signature"></span>find<span class="signature">(query, firstOnly<span class="signature-attributes">opt</span>)</span><span class="type-signature"> &rarr; {<a href="Resultset.html">Resultset</a>}</span></h4>
    

    



<div class="description">
    <p>Used for querying via a mongo-style query object.</p>
</div>









    <h5>Parameters:</h5>
    

<table class="params">
    <thead>
    <tr>
        
        <th>Name</th>
        

        <th>Type</th>

        
        <th>Attributes</th>
        

        

        <th class="last">Description</th>
    </tr>
    </thead>

    <tbody>
    

        <tr>
            
                <td class="name"><code>query</code></td>
            

            <td class="type">
            
                
<span class="param-type">object</span>


            
            </td>

            
                <td class="attributes">
                

                

                
                </td>
            

            

            <td class="description last"><p>A mongo-style query object used for filtering current results.</p></td>
        </tr>

    

        <tr>
            
                <td class="name"><code>firstOnly</code></td>
            

            <td class="type">
            
                
<span class="param-type">boolean</span>


            
            </td>

            
                <td class="attributes">
                
                    &lt;optional><br>
                

                

                
                </td>
            

            

            <td class="description last"><p>(Optional) Used by collection.findOne()</p></td>
        </tr>

    
    </tbody>
</table>






<dl class="details">

    

    

    

    

    

    

    

    

    

    

    

    

    
    <dt class="tag-source">Source:</dt>
    <dd class="tag-source"><ul class="dummy"><li>
        <a href="lokijs.js.html">lokijs.js</a>, <a href="lokijs.js.html#line3256">line 3256</a>
    </li></ul></dd>
    

    

    

    
</dl>













<h5>Returns:</h5>

        
<div class="param-desc">
    <p>this resultset for further chain ops.</p>
</div>



<dl>
    <dt>
        Type
    </dt>
    <dd>
        
<span class="param-type"><a href="Resultset.html">Resultset</a></span>


    </dd>
</dl>

    




    <h5>Example</h5>
    
    <pre class="prettyprint"><code>var over30 = users.chain().find({ age: { $gte: 30 } }).data();</code></pre>



        
            

    

    
    <h4 class="name" id="map"><span class="type-signature"></span>map<span class="signature">(mapFun, dataOptions<span class="signature-attributes">opt</span>)</span><span class="type-signature"></span></h4>
    

    



<div class="description">
    <p>Applies a map function into a new collection for further chaining.</p>
</div>









    <h5>Parameters:</h5>
    

<table class="params">
    <thead>
    <tr>
        
        <th>Name</th>
        

        <th>Type</th>

        
        <th>Attributes</th>
        

        

        <th class="last">Description</th>
    </tr>
    </thead>

    <tbody>
    

        <tr>
            
                <td class="name"><code>mapFun</code></td>
            

            <td class="type">
            
                
<span class="param-type">function</span>


            
            </td>

            
                <td class="attributes">
                

                

                
                </td>
            

            

            <td class="description last"><p>javascript map function</p></td>
        </tr>

    

        <tr>
            
                <td class="name"><code>dataOptions</code></td>
            

            <td class="type">
            
                
<span class="param-type">object</span>


            
            </td>

            
                <td class="attributes">
                
                    &lt;optional><br>
                

                

                
                </td>
            

            

            <td class="description last"><p>options to data() before input to your map function</p>
                <h6>Properties</h6>
                

<table class="params">
    <thead>
    <tr>
        
        <th>Name</th>
        

        <th>Type</th>

        

        

        <th class="last">Description</th>
    </tr>
    </thead>

    <tbody>
    

        <tr>
            
                <td class="name"><code>removeMeta</code></td>
            

            <td class="type">
            
                
<span class="param-type">bool</span>


            
            </td>

            

            

            <td class="description last"><p>allows removing meta before calling mapFun</p></td>
        </tr>

    

        <tr>
            
                <td class="name"><code>forceClones</code></td>
            

            <td class="type">
            
                
<span class="param-type">boolean</span>


            
            </td>

            

            

            <td class="description last"><p>forcing the return of cloned objects to your map object</p></td>
        </tr>

    

        <tr>
            
                <td class="name"><code>forceCloneMethod</code></td>
            

            <td class="type">
            
                
<span class="param-type">string</span>


            
            </td>

            

            

            <td class="description last"><p>Allows overriding the default or collection specified cloning method.</p></td>
        </tr>

    
    </tbody>
</table>

            </td>
        </tr>

    
    </tbody>
</table>






<dl class="details">

    

    

    

    

    

    

    

    

    

    

    

    

    
    <dt class="tag-source">Source:</dt>
    <dd class="tag-source"><ul class="dummy"><li>
        <a href="lokijs.js.html">lokijs.js</a>, <a href="lokijs.js.html#line3853">line 3853</a>
    </li></ul></dd>
    

    

    

    
</dl>

















    <h5>Example</h5>
    
    <pre class="prettyprint"><code>var orders.chain().find({ productId: 32 }).map(function(obj) {  return {    orderId: $loki,    productId: productId,    quantity: qty  };});</code></pre>



        
            

    

    
    <h4 class="name" id="mapReduce"><span class="type-signature"></span>mapReduce<span class="signature">(mapFunction, reduceFunction)</span><span class="type-signature"> &rarr; {value}</span></h4>
    

    



<div class="description">
    <p>data transformation via user supplied functions</p>
</div>









    <h5>Parameters:</h5>
    

<table class="params">
    <thead>
    <tr>
        
        <th>Name</th>
        

        <th>Type</th>

        

        

        <th class="last">Description</th>
    </tr>
    </thead>

    <tbody>
    

        <tr>
            
                <td class="name"><code>mapFunction</code></td>
            

            <td class="type">
            
                
<span class="param-type">function</span>


            
            </td>

            

            

            <td class="description last"><p>this function accepts a single document for you to transform and return</p></td>
        </tr>

    

        <tr>
            
                <td class="name"><code>reduceFunction</code></td>
            

            <td class="type">
            
                
<span class="param-type">function</span>


            
            </td>

            

            

            <td class="description last"><p>this function accepts many (array of map outputs) and returns single value</p></td>
        </tr>

    
    </tbody>
</table>






<dl class="details">

    

    

    

    

    

    

    

    

    

    

    

    

    
    <dt class="tag-source">Source:</dt>
    <dd class="tag-source"><ul class="dummy"><li>
        <a href="lokijs.js.html">lokijs.js</a>, <a href="lokijs.js.html#line3721">line 3721</a>
    </li></ul></dd>
    

    

    

    
</dl>













<h5>Returns:</h5>

        
<div class="param-desc">
    <p>The output of your reduceFunction</p>
</div>



<dl>
    <dt>
        Type
    </dt>
    <dd>
        
<span class="param-type">value</span>


    </dd>
</dl>

    




    <h5>Example</h5>
    
    <pre class="prettyprint"><code>var db = new loki("order.db");var orders = db.addCollection("orders");orders.insert([{ qty: 4, unitCost: 100.00 }, { qty: 10, unitCost: 999.99 }, { qty: 2, unitCost: 49.99 }]);function mapfun (obj) { return obj.qty*obj.unitCost };function reducefun(array) {  var grandTotal=0;  array.forEach(function(orderTotal) { grandTotal += orderTotal; });  return grandTotal;}var grandOrderTotal = orders.chain().mapReduce(mapfun, reducefun);console.log(grandOrderTotal);</code></pre>



        
            

    

    
    <h4 class="name" id="remove"><span class="type-signature"></span>remove<span class="signature">()</span><span class="type-signature"> &rarr; {<a href="Resultset.html">Resultset</a>}</span></h4>
    

    



<div class="description">
    <p>Removes all document objects which are currently in resultset from collection (as well as resultset)</p>
</div>













<dl class="details">

    

    

    

    

    

    

    

    

    

    

    

    

    
    <dt class="tag-source">Source:</dt>
    <dd class="tag-source"><ul class="dummy"><li>
        <a href="lokijs.js.html">lokijs.js</a>, <a href="lokijs.js.html#line3686">line 3686</a>
    </li></ul></dd>
    

    

    

    
</dl>













<h5>Returns:</h5>

        
<div class="param-desc">
    <p>this (empty) resultset for further chain ops.</p>
</div>



<dl>
    <dt>
        Type
    </dt>
    <dd>
        
<span class="param-type"><a href="Resultset.html">Resultset</a></span>


    </dd>
</dl>

    




    <h5>Example</h5>
    
    <pre class="prettyprint"><code>// remove users inactive since 1/1/2001users.chain().find({ lastActive: { $lte: new Date("1/1/2001").getTime() } }).remove();</code></pre>



        
            

    

    
    <h4 class="name" id="simplesort"><span class="type-signature"></span>simplesort<span class="signature">(propname, options)</span><span class="type-signature"> &rarr; {<a href="Resultset.html">Resultset</a>}</span></h4>
    

    



<div class="description">
    <p>Simpler, loose evaluation for user to sort based on a property name. (chainable).
   Sorting based on the same lt/gt helper functions used for binary indices.</p>
</div>









    <h5>Parameters:</h5>
    

<table class="params">
    <thead>
    <tr>
        
        <th>Name</th>
        

        <th>Type</th>

        

        

        <th class="last">Description</th>
    </tr>
    </thead>

    <tbody>
    

        <tr>
            
                <td class="name"><code>propname</code></td>
            

            <td class="type">
            
                
<span class="param-type">string</span>


            
            </td>

            

            

            <td class="description last"><p>name of property to sort by.</p></td>
        </tr>

    

        <tr>
            
                <td class="name"><code>options</code></td>
            

            <td class="type">
            
                
<span class="param-type">object</span>
|

<span class="param-type">bool</span>


            
            </td>

            

            

            <td class="description last"><p>boolean to specify if isdescending, or options object</p>
                <h6>Properties</h6>
                

<table class="params">
    <thead>
    <tr>
        
        <th>Name</th>
        

        <th>Type</th>

        
        <th>Attributes</th>
        

        
        <th>Default</th>
        

        <th class="last">Description</th>
    </tr>
    </thead>

    <tbody>
    

        <tr>
            
                <td class="name"><code>desc</code></td>
            

            <td class="type">
            
                
<span class="param-type">boolean</span>


            
            </td>

            
                <td class="attributes">
                
                    &lt;optional><br>
                

                

                
                </td>
            

            
                <td class="default">
                
                    false
                
                </td>
            

            <td class="description last"><p>whether to sort descending</p></td>
        </tr>

    

        <tr>
            
                <td class="name"><code>disableIndexIntersect</code></td>
            

            <td class="type">
            
                
<span class="param-type">boolean</span>


            
            </td>

            
                <td class="attributes">
                
                    &lt;optional><br>
                

                

                
                </td>
            

            
                <td class="default">
                
                    false
                
                </td>
            

            <td class="description last"><p>whether we should explicity not use array intersection.</p></td>
        </tr>

    

        <tr>
            
                <td class="name"><code>forceIndexIntersect</code></td>
            

            <td class="type">
            
                
<span class="param-type">boolean</span>


            
            </td>

            
                <td class="attributes">
                
                    &lt;optional><br>
                

                

                
                </td>
            

            
                <td class="default">
                
                    false
                
                </td>
            

            <td class="description last"><p>force array intersection (if binary index exists).</p></td>
        </tr>

    

        <tr>
            
                <td class="name"><code>useJavascriptSorting</code></td>
            

            <td class="type">
            
                
<span class="param-type">boolean</span>


            
            </td>

            
                <td class="attributes">
                
                    &lt;optional><br>
                

                

                
                </td>
            

            
                <td class="default">
                
                    false
                
                </td>
            

            <td class="description last"><p>whether results are sorted via basic javascript sort.</p></td>
        </tr>

    
    </tbody>
</table>

            </td>
        </tr>

    
    </tbody>
</table>






<dl class="details">

    

    

    

    

    

    

    

    

    

    

    

    

    
    <dt class="tag-source">Source:</dt>
    <dd class="tag-source"><ul class="dummy"><li>
        <a href="lokijs.js.html">lokijs.js</a>, <a href="lokijs.js.html#line3011">line 3011</a>
    </li></ul></dd>
    

    

    

    
</dl>













<h5>Returns:</h5>

        
<div class="param-desc">
    <p>Reference to this resultset, sorted, for future chain operations.</p>
</div>



<dl>
    <dt>
        Type
    </dt>
    <dd>
        
<span class="param-type"><a href="Resultset.html">Resultset</a></span>


    </dd>
</dl>

    




    <h5>Example</h5>
    
    <pre class="prettyprint"><code>var results = users.chain().simplesort('age').data();</code></pre>



        
            

    

    
    <h4 class="name" id="sort"><span class="type-signature"></span>sort<span class="signature">(comparefun)</span><span class="type-signature"> &rarr; {<a href="Resultset.html">Resultset</a>}</span></h4>
    

    



<div class="description">
    <p>User supplied compare function is provided two documents to compare. (chainable)</p>
</div>









    <h5>Parameters:</h5>
    

<table class="params">
    <thead>
    <tr>
        
        <th>Name</th>
        

        <th>Type</th>

        

        

        <th class="last">Description</th>
    </tr>
    </thead>

    <tbody>
    

        <tr>
            
                <td class="name"><code>comparefun</code></td>
            

            <td class="type">
            
                
<span class="param-type">function</span>


            
            </td>

            

            

            <td class="description last"><p>A javascript compare function used for sorting.</p></td>
        </tr>

    
    </tbody>
</table>






<dl class="details">

    

    

    

    

    

    

    

    

    

    

    

    

    
    <dt class="tag-source">Source:</dt>
    <dd class="tag-source"><ul class="dummy"><li>
        <a href="lokijs.js.html">lokijs.js</a>, <a href="lokijs.js.html#line2978">line 2978</a>
    </li></ul></dd>
    

    

    

    
</dl>













<h5>Returns:</h5>

        
<div class="param-desc">
    <p>Reference to this resultset, sorted, for future chain operations.</p>
</div>



<dl>
    <dt>
        Type
    </dt>
    <dd>
        
<span class="param-type"><a href="Resultset.html">Resultset</a></span>


    </dd>
</dl>

    




    <h5>Example</h5>
    
    <pre class="prettyprint"><code>rslt.sort(function(obj1, obj2) {     if (obj1.name === obj2.name) return 0;     if (obj1.name > obj2.name) return 1;     if (obj1.name &lt; obj2.name) return -1;   });</code></pre>



        
            

    

    
    <h4 class="name" id="transform"><span class="type-signature"></span>transform<span class="signature">(transform, parameters<span class="signature-attributes">opt</span>)</span><span class="type-signature"> &rarr; {<a href="Resultset.html">Resultset</a>}</span></h4>
    

    



<div class="description">
    <p>transform() - executes a named collection transform or raw array of transform steps against the resultset.</p>
</div>









    <h5>Parameters:</h5>
    

<table class="params">
    <thead>
    <tr>
        
        <th>Name</th>
        

        <th>Type</th>

        
        <th>Attributes</th>
        

        

        <th class="last">Description</th>
    </tr>
    </thead>

    <tbody>
    

        <tr>
            
                <td class="name"><code>transform</code></td>
            

            <td class="type">
            
                
<span class="param-type">string</span>
|

<span class="param-type">array</span>


            
            </td>

            
                <td class="attributes">
                

                

                
                </td>
            

            

            <td class="description last"><p>name of collection transform or raw transform array</p></td>
        </tr>

    

        <tr>
            
                <td class="name"><code>parameters</code></td>
            

            <td class="type">
            
                
<span class="param-type">object</span>


            
            </td>

            
                <td class="attributes">
                
                    &lt;optional><br>
                

                

                
                </td>
            

            

            <td class="description last"><p>(Optional) object property hash of parameters, if the transform requires them.</p></td>
        </tr>

    
    </tbody>
</table>






<dl class="details">

    

    

    

    

    

    

    

    

    

    

    

    

    
    <dt class="tag-source">Source:</dt>
    <dd class="tag-source"><ul class="dummy"><li>
        <a href="lokijs.js.html">lokijs.js</a>, <a href="lokijs.js.html#line2894">line 2894</a>
    </li></ul></dd>
    

    

    

    
</dl>













<h5>Returns:</h5>

        
<div class="param-desc">
    <p>either (this) resultset or a clone of of this resultset (depending on steps)</p>
</div>



<dl>
    <dt>
        Type
    </dt>
    <dd>
        
<span class="param-type"><a href="Resultset.html">Resultset</a></span>


    </dd>
</dl>

    




    <h5>Example</h5>
    
    <pre class="prettyprint"><code>users.addTransform('CountryFilter', [  {    type: 'find',    value: {      'country': { $eq: '[%lktxp]Country' }    }  },  {    type: 'simplesort',    property: 'age',    options: { desc: false}  }]);var results = users.chain().transform("CountryFilter", { Country: 'fr' }).data();</code></pre>



        
            

    

    
    <h4 class="name" id="update"><span class="type-signature"></span>update<span class="signature">(updateFunction)</span><span class="type-signature"> &rarr; {<a href="Resultset.html">Resultset</a>}</span></h4>
    

    



<div class="description">
    <p>Used to run an update operation on all documents currently in the resultset.</p>
</div>









    <h5>Parameters:</h5>
    

<table class="params">
    <thead>
    <tr>
        
        <th>Name</th>
        

        <th>Type</th>

        

        

        <th class="last">Description</th>
    </tr>
    </thead>

    <tbody>
    

        <tr>
            
                <td class="name"><code>updateFunction</code></td>
            

            <td class="type">
            
                
<span class="param-type">function</span>


            
            </td>

            

            

            <td class="description last"><p>User supplied updateFunction(obj) will be executed for each document object.</p></td>
        </tr>

    
    </tbody>
</table>






<dl class="details">

    

    

    

    

    

    

    

    

    

    

    

    

    
    <dt class="tag-source">Source:</dt>
    <dd class="tag-source"><ul class="dummy"><li>
        <a href="lokijs.js.html">lokijs.js</a>, <a href="lokijs.js.html#line3645">line 3645</a>
    </li></ul></dd>
    

    

    

    
</dl>













<h5>Returns:</h5>

        
<div class="param-desc">
    <p>this resultset for further chain ops.</p>
</div>



<dl>
    <dt>
        Type
    </dt>
    <dd>
        
<span class="param-type"><a href="Resultset.html">Resultset</a></span>


    </dd>
</dl>

    




    <h5>Example</h5>
    
    <pre class="prettyprint"><code>users.chain().find({ country: 'de' }).update(function(user) {  user.phoneFormat = "+49 AAAA BBBBBB";});</code></pre>



        
            

    

    
    <h4 class="name" id="where"><span class="type-signature"></span>where<span class="signature">(fun)</span><span class="type-signature"> &rarr; {<a href="Resultset.html">Resultset</a>}</span></h4>
    

    



<div class="description">
    <p>where() - Used for filtering via a javascript filter function.</p>
</div>









    <h5>Parameters:</h5>
    

<table class="params">
    <thead>
    <tr>
        
        <th>Name</th>
        

        <th>Type</th>

        

        

        <th class="last">Description</th>
    </tr>
    </thead>

    <tbody>
    

        <tr>
            
                <td class="name"><code>fun</code></td>
            

            <td class="type">
            
                
<span class="param-type">function</span>


            
            </td>

            

            

            <td class="description last"><p>A javascript function used for filtering current results by.</p></td>
        </tr>

    
    </tbody>
</table>






<dl class="details">

    

    

    

    

    

    

    

    

    

    

    

    

    
    <dt class="tag-source">Source:</dt>
    <dd class="tag-source"><ul class="dummy"><li>
        <a href="lokijs.js.html">lokijs.js</a>, <a href="lokijs.js.html#line3489">line 3489</a>
    </li></ul></dd>
    

    

    

    
</dl>













<h5>Returns:</h5>

        
<div class="param-desc">
    <p>this resultset for further chain ops.</p>
</div>



<dl>
    <dt>
        Type
    </dt>
    <dd>
        
<span class="param-type"><a href="Resultset.html">Resultset</a></span>


    </dd>
</dl>

    




    <h5>Example</h5>
    
    <pre class="prettyprint"><code>var over30 = users.chain().where(function(obj) { return obj.age >= 30; }.data();</code></pre>



        
    

    

    
</article>

</section>




</div>

<nav>
    <h2><a href="index.html">Home</a></h2><h3>Classes</h3><ul><li><a href="Collection.html">Collection</a></li><li><a href="DynamicView.html">DynamicView</a></li><li><a href="Loki.html">Loki</a></li><li><a href="LokiEventEmitter.html">LokiEventEmitter</a></li><li><a href="LokiFsAdapter.html">LokiFsAdapter</a></li><li><a href="LokiFsStructuredAdapter.html">LokiFsStructuredAdapter</a></li><li><a href="LokiIndexedAdapter.html">LokiIndexedAdapter</a></li><li><a href="LokiLocalStorageAdapter.html">LokiLocalStorageAdapter</a></li><li><a href="LokiMemoryAdapter.html">LokiMemoryAdapter</a></li><li><a href="LokiPartitioningAdapter.html">LokiPartitioningAdapter</a></li><li><a href="Resultset.html">Resultset</a></li></ul><h3>Tutorials</h3><ul><li><a href="tutorial-Autoupdating Collections.html">Autoupdating Collections</a></li><li><a href="tutorial-Changes API.html">Changes API</a></li><li><a href="tutorial-Collection Transforms.html">Collection Transforms</a></li><li><a href="tutorial-Indexing and Query performance.html">Indexing and Query performance</a></li><li><a href="tutorial-Loki Angular.html">Loki Angular</a></li><li><a href="tutorial-Persistence Adapters.html">Persistence Adapters</a></li><li><a href="tutorial-Query Examples.html">Query Examples</a></li></ul>
</nav>

<br class="clear">

<footer>
    Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 3.5.5</a> on Thu May 10 2018 03:42:33 GMT-0400 (Eastern Daylight Time)
</footer>

<script> prettyPrint(); </script>
<script src="scripts/linenumber.js"> </script>
</body>
</html>